package com.yuan.base.service.api;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;

/**
 * 分页数据
 *
 * @author lintiangang
 * @date 2021/03/26 14:36
 **/
@Data
public class ComPage<T> implements Serializable {


    private static final long serialVersionUID = -4276458372702581870L;
    /**
     * 数据
     */
    private List<T> list;

    /**
     * 总数
     */
    private Long total;

    /**
     * 当前页
     */
    private Integer current;

    /**
     * 一页大小
     */
    private Integer size;

    private Boolean finished;

    public Boolean getFinished() {
        if (finished != null) {
            return finished;
        }
        try {
            if (CollectionUtils.isEmpty(list)) {
                return true;
            }
            finished = (total <= (current * size));
            return finished;
        } catch (Exception e) {
            return false;
        }
    }
}
